library ieee;
use IEEE.numeric_std.all;
use ieee.std_logic_1164.all;

entity Snake_Movement_Controller is 
	port (
	trigger, init			: in std_logic;
	angle					: in unsigned(2 downto 0);
	next_x					: out unsigned(9 downto 0);
	next_y					: out unsigned(9 downto 0);
	init_x					: in unsigned(9 downto 0);
	init_y					: in unsigned(9 downto 0)
	);
end entity;

Architecture arch1 of Snake_Movement_Controller is
	signal X			: unsigned(9 downto 0);
	signal Y			: unsigned(9 downto 0);
begin
	next_x <= X;
	next_y <= Y;
	process(trigger,init,init_x,init_y)
	begin
		if(init = '1') then
				X <= init_x;
				Y <= init_y;
		elsif(trigger = '1' and trigger'event) then
				if(angle = 0) then
					Y <= Y;
					X <= X + 1;
				elsif(angle = 1) then
					Y <= Y + 1;
					X <= X + 1;
				elsif(angle = 2) then
					Y <= Y + 1;
					X <= X;
				elsif(angle = 3) then
					Y <= Y + 1;
					X <= X - 1;
				elsif(angle = 4) then
					Y <= Y;
					X <= X - 1;
				elsif(angle = 5) then
					Y <= Y - 1;
					X <= X -1;
				elsif(angle = 6) then
					Y <= Y - 1;
					X <= X;
				elsif(angle = 7) then
					Y <= Y - 1;
					X <= X + 1;
				end if;
		end if;
	end process;
end arch1;